package com.wanshi.servlet;

import com.alibaba.fastjson.JSON;
import com.wanshi.dao.AreaDao;
import com.wanshi.entity.Sheng;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/ProvinceServlet")
public class ProvinceServlet extends HttpServlet {

    private AreaDao areaDao = new AreaDao();
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //获取所有省
        List<Sheng> list = areaDao.getShengs();
        response.getWriter().write(JSON.toJSONString(list));
    }
}
